package agentFree2;

import java.util.List;
import java.util.regex.*;
import javax.jdo.*;

public class Utils {
	public static boolean isRealAgent(Long phoneNumber){

		PersistenceManager pm = PMF.get().getPersistenceManager();

		Query query = pm.newQuery(Agent.class,"phoneNumber == "+phoneNumber+"");

        List<Agent> results = (List<Agent>) query.execute("Smith");

        if (!results.isEmpty()) {
        	query.closeAll();
        	return true;
        }
        else{
        	query.closeAll();
        	return false;
        }
        
		
	}
	public static String findFirstMatcher(String s, String  regex){
		Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
		Matcher matcher = pattern.matcher(s);
		matcher.find();
		return 	matcher.group();
	} 
}
